package com.baizhi.service.impl;

import dao.UserDao;
import entity.User;
import org.apache.ibatis.session.SqlSession;
import com.baizhi.service.UserService;
import util.MyBatisUtils;

public class UserServiceImpl implements UserService {
    @Override
    public boolean Login(String name,String pwd) {
        SqlSession sqlSession = MyBatisUtils.openSession();
        try {
            UserDao mapper = sqlSession.getMapper(UserDao.class);
            User user = mapper.findUser();
            if (name.equals(user.getUsername()) && pwd.equals(user.getPassword())) {
                return  true;
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            MyBatisUtils.close(sqlSession);
        }
        return  false;
    }
}
